#include <stdio.h>
#include <unistd.h>


void printProgress(double total ,double complete)
{
    
    int i =(int)complete/total*100;
   // 进度条图形
   printf("[");
  int j = 0;
  for(;j<=i;j+=2)
       printf("#");
  for(;j<=100;j+=2)
       printf(" ");
  printf("]");
        //进度条百分比
        printf("[");
        printf("%02d%%",i);
        printf("]");
        //进度条 /|\ 循环
        static int z = 0;
        printf("[");
        if(z%4 == 0)
            printf("/");
        if(z%4 == 1)
            printf("-");
        if(z%4 == 2)
            printf("\\");
        if(z%4 == 3)
            printf("|");
        printf("]");
        z++;
        fflush(stdout);
        printf("\r");
        usleep(10*1000);
}

int main()
{
    double total = 1024.0;
    double speed = 1.0;
    double complte = 0.0;
    while(complte <= total)
    {
        printProgress(total,complte);
        complte += speed;
    }
    
    printf("\n");
    printf("下载成功！！！");



    return 0;
}
